package com.findu.control;

import java.io.InputStream;
import java.net.URL;
import java.util.List;

import com.example.findu.R;



import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Home_Relatives_list_MYAdapter extends BaseAdapter{
	private Context context;
	private List<Home_Relatives_list_App> text;
	private TextView textView1,textView2;
	private ImageView imageView;
	
	public Home_Relatives_list_MYAdapter(Context context,List<Home_Relatives_list_App> text){
		this.context = context;
		this.text = text;
	}
	@Override
	public int getCount() {
		return text.size();
	}

	@Override
	public Object getItem(int position) {
		return text.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final int index = position;	//�õ���ѡ��
		View view = convertView;	//�õ���ͼ
		//�����ͼΪ�վͼ���
		if(view == null){
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
			//��View�õ�item�ļ�
			view = inflater.inflate(R.layout.home_conversation_list_item, null);
		}
		textView1 = (TextView) view.findViewById(R.id.item_textView1);
		textView2 = (TextView) view.findViewById(R.id.item_textView2);
		textView1.setText(text.get(index).getName());
		textView2.setText(text.get(index).getRelatives());
		
		//��ʼ��ͼƬ���
		//imageView = (ImageView) view.findViewById(R.id.item_imageView);
		
		//��ȡͼƬ�߳�
		/*new Thread(new Runnable() {
			public void run() {
				String imageAddress = text.get(index).getThumb();				
				// ��ȡͼƬ��Դ
				Bitmap bitmap = null;				
				try {
					//���÷�������ͼƬ��
					 bitmap =showImage(imageAddress);					 
					 //�����صĽ�����õ�ͼƬ��
					//imageView.setImageBitmap(bitmap);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
						
		}).start();*/

		return view;
	}
	//�����ȡͼƬ
/*	private  Bitmap showImage(String imageName) {
		// ��ȡͼƬ��Դ
		Bitmap bitmap = null;	
		try {
			final URL url;
			url = new URL(imageName);
			InputStream isStream = url.openStream(); // ��ȡ������
			// �õ�ͼƬ��
			bitmap = BitmapFactory.decodeStream(isStream);
		} catch (Exception e) {
			e.printStackTrace();
		}

	return bitmap;}
*/

}
